package leetcode.code;

import java.util.ArrayList;
import java.util.List;

import leetcode.helper.tree.TreeNode;

public class Solution144 {
	List<Integer> ans;
    public List<Integer> preorderTraversal(TreeNode root) {
    	ans = new ArrayList<>();
    	this.preorder(root);
    	return ans;
    }
	private void preorder(TreeNode root) {
		if(root ==null) {
			return;
		}
		ans.add(root.val);
		this.preorder(root.left);
		this.preorder(root.right);
	}
}
